From 045254ed20dce0f78c2f83921d1cb738b85e6cbb Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 3 Sep 2014 17:36:41 -0700 Subject: [PATCH] Do not pass static lib targets to rustc --- src/cargo/ops/cargo_rustc/mod.rs | 4 ++++ tests/test_cargo_compile.rs | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index a4d1c60af..f9cb09631 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -405,6 +405,10 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package, if target.is_bin() { for target in targets { + if target.is_staticlib() { + continue; + } + cmd = try!(link_to(cmd, target, cx, kind, LocalLib)); } } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index ace545bc2..9c754cc34 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1466,6 +1466,29 @@ test!(simple_staticlib { assert_that(p.cargo_process("build"), execs().with_status(0)); }) +test!(staticlib_rlib_and_bin { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + authors = [] + version = "0.0.1" + + [lib] + name = "foo" + crate-type = ["staticlib", "rlib"] + "#) + .file("src/lib.rs", "pub fn foo() {}") + .file("src/main.rs", r#" + extern crate foo; + + fn main() { + foo::foo(); + }"#); + + assert_that(p.cargo_process("build"), execs().with_status(0)); +}) + test!(opt_out_of_lib { let p = project("foo") .file("Cargo.toml", r#" -- 2.30.2